﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
using Artech.PetShop.Common;
using Artech.PetShop.Infrastructures.Interface;
using Artech.PetShop.Products.Service.Interface;

namespace Artech.PetShop.Orders
{
   public class ProductsPresenter : PresenterBase<IProductsView>
    {
        public ProductsPresenter(IProductsView view)
            : base(view)
        { }

        private IProductService _productService = ServiceProxyFactory.Create<IProductService>("productservice");

        public void ListAllProducts()
        {
            this.View.BindAllProducts(this._productService.GetAllProducts());
        }

        public void AddProductInShopCart(Guid productID)
        {
            if (productID == Guid.Empty)
            {
                throw new ArgumentNullException("productID");
            }

            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("productid", productID);
            ServiceLoader.LoadService<INavigatorService>().Navigate("~/ShoppingCart.aspx", parameters);
        }
    }
}
